home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / Apple Game Sprockets / InputSprocket / Sample Drivers / Common Driver Code / ListUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-17  |  2.8 KB  |  101 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************
  2.  
  3. File:      ListUtils.h
  4.  
  5. Copyright © 1996, 1997, 1998 Apple Computer, Inc., All Rights Reserved
  6.  
  7.  
  8. You may incorporate this sample code into your applications without
  9. restriction, though the sample code has been provided "AS IS" and the
  10. responsibility for its operation is 100% yours.  However, what you are
  11. not permitted to do is to redistribute the source as "DSC Sample Code"
  12. after having made changes. If you're going to re-distribute the source,
  13. we require that you make it clear in the source that the code was
  14. descended from Apple Sample Code, but that you've made changes.
  15.  
  16. *************************************************************************************/
  17.  
  18.  
  19. #ifndef _LISTUTILS_H_
  20. #define _LISTUTILS_H_
  21.  
  22. #ifndef __MACTYPES__
  23. #include <MacTypes.h>
  24. #endif
  25.  
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29.  
  30. /*
  31. ************************************************************************
  32. ** constants
  33. ************************************************************************
  34. */
  35. /* iteration directions */
  36. #define kListNotIterating        0
  37. #define kListIterateForward        1
  38. #define kListIterateBackward    2
  39.  
  40. /* node add locations */
  41. #define kListDontAdd            0
  42. #define kListAddTail            1
  43. #define kListAddHead            2
  44.  
  45. /*
  46. ************************************************************************
  47. ** data types
  48. ************************************************************************
  49. */
  50. typedef UInt32 ListIterationDirection;
  51. typedef UInt32 ListNodeAddLocation;
  52.  
  53. typedef struct ListNode {
  54.     struct ListNode *next;
  55.     struct ListNode *prev;
  56.     void *data;
  57. } ListNode;
  58.  
  59. typedef struct List {
  60.     ListNode *head;
  61.     ListNode *tail;
  62.     ListNode *curr;
  63.     UInt32 iterationDirection;
  64. } List;
  65.  
  66. /*
  67. ************************************************************************
  68. ** prototypes
  69. ************************************************************************
  70. */
  71. List *List_New( void );
  72. void List_Dispose( List *inList );
  73. void List_Initialize( List *inList );
  74.  
  75. ListNode *List_NewNode( List *inList,
  76.             ListNodeAddLocation inAddLocation );
  77. void List_DisposeNode( ListNode *inNode );
  78.  
  79. ListNode *List_GetHead( List *inList );
  80. ListNode *List_GetTail( List *inList );
  81.  
  82. void List_AddHead( List *inList, ListNode *inNode );
  83. void List_AddTail( List *inList, ListNode *inNode );
  84.  
  85. void *List_RemoveHead( List *inList );
  86. void *List_RemoveTail( List *inList );
  87. void *List_RemoveNode( List *inList, ListNode *inNode );
  88. void *List_RemoveNodeByData( List *inList, void *inNodeData );
  89.  
  90. ListIterationDirection List_GetIterationState( List *inList );
  91. Boolean List_BeginIteration( List *inList,
  92.             ListIterationDirection inIterateDirection,
  93.             Boolean inBlockWhileBusyFlag );
  94. void List_EndIteration( List *inList );
  95. void *List_Iterate( List *inList );
  96.  
  97. #ifdef __cplusplus
  98. }
  99. #endif
  100.  
  101. #endif /* _LISTUTILS_H_ */